load("//go:def.bzl", "go_binary", "go_source", "go_test")
load("//go/private/rules:transition.bzl", "go_reset_target")

go_test(
    name = "filter_test",
    size = "small",
    srcs = [
        "filter.go",
        "filter_test.go",
        "read.go",
    ],
)

filegroup(
    name = "builder_srcs",
    srcs = [
        "ar.go",
        "asm.go",
        "builder.go",
        "cgo2.go",
        "compile.go",
        "compilepkg.go",
        "cover.go",
        "embedcfg.go",
        "env.go",
        "filter.go",
        "filter_buildid.go",
        "flags.go",
        "generate_nogo_main.go",
        "generate_test_main.go",
        "imports.go",
        "importcfg.go",
        "link.go",
        "pack.go",
        "read.go",
        "replicate.go",
        "stdlib.go",
    ] + select({
        "@bazel_tools//src/conditions:windows": ["path_windows.go"],
        "//conditions:default": ["path.go"],
    }),
    visibility = ["//visibility:public"],
)

go_binary(
    name = "embed",
    srcs = ["embed.go"],
    visibility = ["//visibility:public"],
)

go_source(
    name = "nogo_srcs",
    srcs = [
        "env.go",
        "flags.go",
        "nogo_main.go",
        "pack.go",
    ],
    # //go/tools/builders:nogo_srcs is considered a different target by
    # Bazel's visibility check than
    # @io_bazel_rules_go//go/tools/builders:nogo_srcs. Only the latter is
    # allowed to depend on
    # @org_golang_x_tools//go/analysis/internal/facts:go_tool_library.
    tags = ["manual"],
    visibility = ["//visibility:public"],
    deps = [
        "@org_golang_x_tools//go/analysis:go_tool_library",
        "@org_golang_x_tools//go/analysis/internal/facts:go_tool_library",
        "@org_golang_x_tools//go/gcexportdata:go_tool_library",
    ],
)

go_binary(
    name = "go_path",
    srcs = [
        "env.go",
        "flags.go",
        "go_path.go",
    ],
    visibility = ["//visibility:public"],
)

go_binary(
    name = "info",
    srcs = [
        "env.go",
        "flags.go",
        "info.go",
    ],
    visibility = ["//visibility:public"],
)

go_binary(
    name = "md5sum",
    srcs = [
        "md5sum.go",
    ],
    visibility = ["//visibility:public"],
)

go_binary(
    name = "go-protoc-bin",
    srcs = [
        "env.go",
        "flags.go",
        "protoc.go",
    ],
    visibility = ["//visibility:private"],
)

go_reset_target(
    name = "go-protoc",
    dep = ":go-protoc-bin",
    visibility = ["//visibility:public"],
)

sh_binary(
    name = "lcov_merger",
    srcs = ["lcov_merger.sh"],
    visibility = ["//visibility:public"],
)

filegroup(
    name = "all_builder_srcs",
    testonly = True,
    srcs = glob(["*.go"]),
    visibility = ["//:__subpackages__"],
)

filegroup(
    name = "all_files",
    testonly = True,
    srcs = glob(["**"]),
    visibility = ["//visibility:public"],
)
